package priv.pront.code.national.acwing.base;

import java.util.Scanner;

public class A799_最长连续不重复子序列 {

        static int n,res = 0;
        static int[] a,b = new int[100010];
        public static void main(String[] args){
            Scanner scanner = new Scanner(System.in);
            n = scanner.nextInt();
            a = new int[n];
            for(int i = 0; i < n; i++){
                a[i] = scanner.nextInt();
            }
            for(int i = 0,j = 0; i < n; i++){
                b[a[i]]++;
                while(b[a[i]] > 1){
                    b[a[j]]--;
                    j++;
                }
                res = Math.max(res,i - j + 1);
            }
            System.out.println(res);
    }
}
